<?php
class Vs_User_Mapper
    extends Vs_Mapper
	
{
	/**
	 * @param string $email
	 * @param string $password
	 * @return object Ws_User
	 */
	public function authenticate ( $email, $password)
	{
		$table = $this->getTable();
				
		$password = Vs_Encryptor::password( $password );
		
		$row = $table->getByAccount( $email, $password );
		
		if( empty($row) ){
			throw new Vs_Exception( Vs_Exception::LOGIN_FAILED );
		}
		
		return $this->_fetch( $row );
	} 
}
